package com.edu.exam.enums.curriculum.questionbank;

/**
 * 规则类型枚举
 * 
 * 验证规则的类型定义
 * 
 * @author System
 * @version 1.0.0
 */
public enum RuleType {
    FORMAT("FORMAT", "格式验证"),
    RANGE("RANGE", "范围验证"),
    LENGTH("LENGTH", "长度验证"),
    PATTERN("PATTERN", "模式验证"),
    BUSINESS("BUSINESS", "业务验证"),
    CUSTOM("CUSTOM", "自定义验证");

    private final String code;
    private final String description;

    RuleType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RuleType fromCode(String code) {
        for (RuleType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return CUSTOM;
    }
}